//
//  AboutProductController.m
//  QuickCure1
//
//  Created by maoge on 16/10/30.
//  Copyright © 2016年 maoge. All rights reserved.
//

#import "AboutProductController.h"
#import "UserProtocolViewController.h"
#import "ProductIntroduceController.h"
#import "SeeADoctorGuideViewController.h"
#import "ProgressManager.h"

@interface BaseViewController ()<UITableViewDataSource,UITableViewDelegate>;

@end
static NSString *CELL_ALONE = @"aloneCell";
@implementation AboutProductController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupUI];
    // Do any additional setup after loading the view.
}

- (void)setupUI{
    //title
    self.title = @"关于用户";
    self.view.backgroundColor = [UIColor colorWithWhite:0.95 alpha:1];
    
    //imageView1
    UIImageView *imageView1 = [[UIImageView alloc]init];
    imageView1.image = [UIImage imageNamed:@"product_img_logo_nor.png"];
    [self.view addSubview:imageView1];
    
    //imageView2
    UIImageView *imageView2 = [[UIImageView alloc]init];
    imageView2.image = [UIImage imageNamed:@"product_text_logo_nor.png"];
    [self.view addSubview:imageView2];
    
    //tableView
    UITableView *tableView1 = [[UITableView alloc]initWithFrame:CGRectMake(0, 333, self.view.frame.size.width, 160) style:UITableViewStylePlain];
    //
    self.tableView = tableView1;
    //register cell
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:CELL_ALONE];
    tableView1.rowHeight = 40;
    //
    tableView1.scrollEnabled = NO;
    //self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    //
    //tableView1.allowsSelection = NO;
    [self.view addSubview:tableView1];
    
    //set tableView delegate
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    
    //label1
    UILabel *label1 = [[UILabel alloc]init];
    label1.text = @"用户交流群:261704292";
    label1.textColor = [UIColor colorWithRed:0.2 green:0.6 blue:0.2 alpha:1];
    [self.view addSubview:label1];
    
    //label2
    UILabel *label2 = [[UILabel alloc]init];
    label2.textColor = kThemeColor;
    label2.text = @"Version:1.4.7";
    [self.view addSubview:label2];
    
    //make constraint
    [imageView1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.height.mas_equalTo(120);
        make.width.mas_equalTo(80);
        make.top.mas_equalTo(self.view).offset(80);
    }];
    
    [imageView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.height.mas_equalTo(70);
        make.width.mas_equalTo(100);
        make.top.mas_equalTo(imageView1.mas_bottom).offset(30);
    }];
    
    [label2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.height.mas_equalTo(50);
        make.width.mas_equalTo(100);
        make.bottom.mas_equalTo(self.view).offset(-20);
    }];
    
    [label1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.height.mas_equalTo(60);
        make.width.mas_equalTo(180);
        make.bottom.equalTo(label2.mas_top).offset(10);
    }];
}
-(void)configureLoginView{
    
//    BOOL isLogin = [MLDefaults boolForKey:kIsUserLoginKey];
    
    if (1) {
        
        [ProgressManager alertInfoStatus:@"已经是最新版本了哦！"];
    }
    
}

#pragma mark - tableView delegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 4;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CELL_ALONE forIndexPath:indexPath];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    if (indexPath.row == 0) {
        cell.textLabel.text = @"就医指导";
        cell.imageView.image = [UIImage imageNamed:@"product_img_icon_xieyi.png"];
        return cell;
    }
    if (indexPath.row == 1){
        cell.textLabel.text = @"检查更新";
        cell.imageView.image = [UIImage imageNamed:@"product_img_icon_xieyi.png"];
    return cell;
    }    if (indexPath.row == 2){
        cell.textLabel.text = @"用户协议";
        cell.imageView.image = [UIImage imageNamed:@"product_img_icon_xieyi.png"];
        return cell;
    }
    cell.textLabel.text = @"版本介绍";
    cell.imageView.image = [UIImage imageNamed:@"product_img_icon_xieyi.png"];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if (indexPath.row == 0) {
        SeeADoctorGuideViewController *seeADoctorGuideViewController = [[SeeADoctorGuideViewController alloc]init];
        [self.navigationController pushViewController:seeADoctorGuideViewController animated:YES];
    }else if (indexPath.row == 3){
        ProductIntroduceController *productIntroduceController = [[ProductIntroduceController alloc]init];
        [self.navigationController pushViewController:productIntroduceController animated:YES];
    }else if (indexPath.row == 1){
        [self configureLoginView];
    }else if (indexPath.row == 2){
        UserProtocolViewController *userProtocolViewController = [[UserProtocolViewController alloc]init];
        [self.navigationController pushViewController:userProtocolViewController animated:YES];
    }
}

@end
